import request from "@/axios/axios.ts";
import {
    BigFuzzySearch,
    SmallFuzzySearch,
    HandleFuzzySearch,
    HandleClassFuzzySearch, SmallFuzzySearchM
} from "@/api/first/FuzzySearch/type.ts";
import {useStore} from '@/pinia'

const store = useStore()

enum API1 {
    BIG = '/first/big_fuzzy_search',
    SMALL = '/first/small_fuzzy_search',
    SMALLM = '/first/small_fuzzy_search_multiple_parameter',
    HANDLE = '/first/handle_fuzzy_search',
    HANDLECLASS = '/first/handle_class_fuzzy_search'
}
enum API2 {
    BIG = '/second/big_fuzzy_search',
    SMALL = '/second/small_fuzzy_search',
    SMALLM = '/second/small_fuzzy_search_multiple_parameter',
    HANDLE = '/second/handle_fuzzy_search',
    HANDLECLASS = '/second/handle_class_fuzzy_search'
}
enum API3 {
    BIG = '/first_new/big_fuzzy_search',
    SMALL = '/first_new/small_fuzzy_search',
    SMALLM = '/first_new/small_fuzzy_search_multiple_parameter',
    HANDLE = '/first_new/handle_fuzzy_search',
    HANDLECLASS = '/first_new/handle_class_fuzzy_search'
}

// 大类名称模糊搜索
export const reqBigFuzzySearch = (data: BigFuzzySearch): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.BIG, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.BIG, data)
    else
        return request.post<any, any>(API3.BIG, data)
}
// 小类名称模糊搜索
export const reqSmallFuzzySearch = (data: SmallFuzzySearch): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.SMALL, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.SMALL, data)
    else
        return request.post<any, any>(API3.SMALL, data)
}

// 小类名称模糊搜索（多条件）
export const reqSmallFuzzySearchM = (data: SmallFuzzySearchM): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.SMALLM, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.SMALLM, data)
    else
        return request.post<any, any>(API3.SMALLM, data)
}

// 处理方模糊搜索
export const reqHandleFuzzySearch = (data: HandleFuzzySearch): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.HANDLE, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.HANDLE, data)
    else
        return request.post<any, any>(API3.HANDLE, data)

}

// 处理方分组模糊搜索
export const reqHandleClassFuzzySearch = (data: HandleClassFuzzySearch): Promise<any> => {
    if (store.axios_path === '1')
        return request.post<any, any>(API1.HANDLECLASS, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.HANDLECLASS, data)
    else
        return request.post<any, any>(API3.HANDLECLASS, data)
}